package com.zhl.thread.cacheline;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-10-13 16:01
 **/
public class CacheLineTest1 {
	public static class T {
		private volatile long a = 0L;
	}
	public static T[] arr = new T[2];
	static {
		arr[0] = new T();
		arr[1] = new T();
	}

	public static void main(String[] args) throws Exception{
		Thread t1 = new Thread(() -> {
			for(long i = 0;i<1000_10000L;i++){
				arr[0].a = i;
			}
		});
		Thread t2 = new Thread(() -> {
			for(long i = 0;i<1000_10000L;i++){
				arr[1].a = i;
			}
		});
		long start = System.nanoTime();
		t1.start();
		t2.start();
		t1.join();
		t2.join();
		System.out.println((System.nanoTime() - start)/100_0000);
	}
}
